package com.bicon.botu.mall.component;

import com.bicon.botu.core.base.annotation.EnableGlobalExceptionHandler;
import com.bicon.botu.core.base.annotation.EnableGlobalRedis;
import com.bicon.botu.core.base.annotation.EnableHttpLogAspect;
import com.bicon.botu.core.base.annotation.EnableSystemInterceptor;
import com.bicon.botu.core.base.config.SystemInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 应用启动类
 * @author tandk
 * @date 2017/7/31 0031 下午 15:24
 */
@SpringBootApplication(scanBasePackages = {"com.bicon"})
@MapperScan("com.bicon.botu.mall.component.mapper") //扫描mapper
@EnableHttpLogAspect //http请求日志
@EnableGlobalExceptionHandler //统一异常处理
@EnableSystemInterceptor //系统拦截器
@EnableGlobalRedis
public class ComponentApplication extends WebMvcConfigurationSupport {

    public static void main(String[] args){
        SpringApplication.run(ComponentApplication.class, args);
    }

    @Bean
    public SystemInterceptor getMyInterceptor(){
        return new SystemInterceptor();
    }

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getMyInterceptor()).addPathPatterns("/**");
    }

}

